package com.um.springboot.starter.configuration;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.web.WebProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 静态资源Api
 *
 * @author 甘天伟
 * @date 2025/2/21
 * 版权所有 广州优匠科技有限公司
 */
@Configuration
@ConditionalOnProperty("hsh.config.static-api")
public class StaticApiConfig implements WebMvcConfigurer {

    @Autowired
    WebProperties webProperties;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/api/v1/static/**").addResourceLocations(webProperties.getResources().getStaticLocations());
    }
}
